import { drawMyQrcode, handlerGobackClick, hint } from "../../../utils/util";
import { Subscribe } from "../../../models/subscribe";
const subscribe = new Subscribe();
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    baseImgUrl: "",
    isVisitor: true,
    showError: true,
    backgroundColor: "#019cf8",
    imageUrl: "",
    phone: "",
    commid: "",
    id: "",
    msg: {},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    if (options.phone) {
      this.setData({
        phone: options.phone,
        commid: options.commid,
        id: options.id,
      });
    }
    if (options.id) {
      this.setData({
        id: options.id,
      });
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.initPageData();
  },
  onShow: function () {
    var { baseImgUrl } = getApp().globalImgUrl.config;
    this.setData({
      baseImgUrl,
    });
  },
  handlerGobackClick,
  refresh() {
    this.selectComponent("#qrcode").refresh();
  },
  initPageData(isShow = false) {
    subscribe
      .auditListById(this.data.id)
      .then((res) => {
        console.log(res, "走走走");

        this.setData({
          msg: res.result,
        });
        if (isShow) {
          hint("已刷新");
        }
      })
      .catch((err) => {
        console.log(err);
      });
  },
  tryUp() {
    this.initPageData(true);
  },
  again() {
    let { ownerName, ownerPhone, visitorName, commid, commname, id, remark } =
      this.data.msg;
    console.log(id);
    wx.navigateTo({
      url: "/owner-app/pages/form-subscribe/index?id=" + id,
    });
  },
});
